var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    suppliers_name:null,
    suppliers_id:0,
    count1:0,
    count2:0,
    count3:0,
    count4:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this 
    wx.request({
      url: 'https://17fx.com/weapp/Adminapi/getadminsuppliers.html',
      data: {
        user_id: app.globalData.userid
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res.data)
        that.setData({
          suppliers_name: res.data.suppliers_name,
          suppliers_id: res.data.suppliers_id,
          count1: res.data.count1,
          count2: res.data.count2,
          count3: res.data.count3,
          count4: res.data.count4
        })
      }
    });
  },
  //扫描验证
  saomayanzhen:function(event){
    // 允许从相机和相册扫码
    wx.scanCode({
      success: (res) => {
        console.log(res)
        console.log(res.result)
        wx.request({
          url: 'https://17fx.com/weapp/Adminapi/getcodeewm.html',
          data: {
            result: res.result,
            user_id: app.globalData.userid
          },
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {
            console.log(res)
            console.log(res.data)
            wx.showModal({
              title: '提示',
              showCancel: false,
              content: res.data,
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定')
                } else if (res.cancel) {
                  console.log('用户点击取消')
                }
              }
            })
          }
        });
      }
    });

  },

  //消费验证
  formSubmit: function (e) {
    console.log('消费验证' + e.detail.value['use_code']);
    var use_code = e.detail.value['use_code'];
    var that = this;
    wx.request({
      url: 'https://17fx.com/weapp/Adminapi/getusercode.html',
      data: {
        use_code: use_code,
        user_id: app.globalData.userid
      },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        console.log(res)
        console.log(res.data)
        wx.showModal({
          title: '提示',
          showCancel:false,
          content: res.data,
          success: function (res) {
            if (res.confirm) {
              console.log('用户点击确定')
            } else if (res.cancel) {
              console.log('用户点击取消')
            }
          }
        })
      }
    });
    
  },

  //核销记录
  hexiaojilu:function(){
    wx.navigateTo({
      url: 'hexiaojilu'
    })
  },

  /**
   * 今日订单 1
   * 今日成交 2
   * 昨日成交 3
   * 等待核销 4
   */
  formorder:function(event){
    var id = event.currentTarget.dataset.id
    wx.navigateTo({
      url: 'adminorder?id='+id
    })
  },

  //跳转到我的店铺
  todetail:function(event){
    var id = event.currentTarget.dataset.id//商店id
    wx.navigateTo({
      url: '../detail/detail?id='+id,
    })
  },

  //跳转到收益订单
  toshouyiorder:function(event){
    wx.navigateTo({
      url: 'adminfanliorder',
    })
  },

  //跳转到我的会员
  tousers:function(event){

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

 

 
})